<template>
  <c-form-dialog
    label-width="140px"
    ref="form"
    class="project-new-form"
    :table-name="formTable"
    :form-items="formItems"
    :form-data="formData"
    :before-save="handleBeforeSave"
    :table-id="tableId"
    :submitText="importStatus === 2 ? '退回' : '拒绝'"
    :visible.sync="innerVisible"
    @close="handleDismiss"
    v-on="$listeners"
  ></c-form-dialog>
</template>

<script>
export default {
  components: {},
  props: {
    visible: Boolean,
    tableId: String,
    formData: { type: Object, default: () => ({}) },
    importStatus: { type: Number, default: 2 },
  },
  data() {
    return {
      formTable: 'datum_one_county_industry',
      innerVisible: false,
      formItems: [
        {
          tag: 'input',
          itemAttrs: {
            label: '退回理由',
            rules: [{ required: true, message: '请输入理由', trigger: 'blur' }],
          },
          attrs: { key: 'back_reason', value: '', placeholder: '请输入理由' },
          getItemAttrs: () => {
            return {
              label: +this.importStatus === 2 ? '退回理由' : '拒绝理由',
            }
          },
        },
      ],
    }
  },
  computed: {},
  watch: {
    visible(val) {
      this.innerVisible = val
    },
  },
  created() {},
  mounted() {},
  methods: {
    handleBeforeSave(model) {
      model.import_status = this.importStatus
      model.datum_status = 0
      return model
    },
    handleDismiss() {
      this.$emit('update:visible', false)
    },
  },
}
</script>

<style lang="scss" scoped></style>
